/*
 *------------------------------------------------------------------------------
 * @File      :    spcs92048_prgb.c
 * @Date      :    2021-3-20
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Source file for MDP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */
#include "ei_comm_panel.h"
#include <fcntl.h>
#include "panel_usr.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

#define PROGRESSIVE_POL		(EI_TRUE)
#define VSYNC_POL		(EI_FALSE)
#define HSYNC_POL		(EI_FALSE)
#define DE_POL			(EI_TRUE)
#define CLK_POL			(EI_FALSE)
#define INVERT(pol)		(pol ? EI_FALSE : EI_TRUE)

#define SPCS92048_WIDTH		(800)
#define SPCS92048_HEIGHT	(480)

#define SPCS92048_HBP		(88)
#define SPCS92048_HFP		(40)
#define SPCS92048_HSW		(128)
#define SPCS92048_HACT		(SPCS92048_WIDTH)
#define SPCS92048_VBP_F1	(33)
#define SPCS92048_VFP_F1	(10)
#define SPCS92048_VSW_F1	(2)
#define SPCS92048_VACT_F1	(SPCS92048_HEIGHT)
#define SPCS92048_VBP_F2	(0)
#define SPCS92048_VFP_F2	(0)
#define SPCS92048_VSW_F2	(0)
#define SPCS92048_VACT_F2	(0)
#define SPCS92048_VT		(SPCS92048_VBP_F1 + SPCS92048_VFP_F1 + SPCS92048_VSW_F1 + SPCS92048_VACT_F1)
#define SPCS92048_DCLK		(33000000) /* 33MHz */

static VO_PUB_ATTR_S spcs92048_config = {
    .enIntfType = VO_INTF_LCD_18BIT,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),

    .stSyncInfo.bIop = PROGRESSIVE_POL,
    .stSyncInfo.bIdv = INVERT(DE_POL),
    .stSyncInfo.bIhs = INVERT(HSYNC_POL),
    .stSyncInfo.bIvs = INVERT(VSYNC_POL),
    .stSyncInfo.bICv = INVERT(CLK_POL),

    .stSyncInfo.u16Hfb = SPCS92048_HFP,
    .stSyncInfo.u16Hpw = SPCS92048_HSW,
    .stSyncInfo.u16Hbb = SPCS92048_HBP,
    .stSyncInfo.u16Hact = SPCS92048_HACT,
    .stSyncInfo.u16Vfb = SPCS92048_VFP_F1,
    .stSyncInfo.u16Vpw = SPCS92048_VSW_F1,
    .stSyncInfo.u16Vbb = SPCS92048_VBP_F1,
    .stSyncInfo.u16Vact = SPCS92048_VACT_F1,
    .stSyncInfo.u32Pclk = SPCS92048_DCLK / 1000,
};

EI_S32 panel_spcs92048_get_panel_attr(PANEL_TYPE_E enPanelType, PANEL_TYPE_ATTR_S *pstPanelAttr)
{
    pstPanelAttr->stVoPubAttr = spcs92048_config;
    return EI_SUCCESS;
}

PANEL_OBJ_S stPanelSpcs92048Obj = {
    .pfnGetPanelAttrByPanel = panel_spcs92048_get_panel_attr,
    .pfnGetPanelInitCodeByPanel = NULL,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

